<template>
  <chart :option="option7" :height="`${height}px`" />
  <chart :option="option8" :height="`${height}px`" />
  <chart :option="option9" :height="`${height}px`" />
</template>

<script setup>
import chart from "@/components/chart/index";
import { echartsApi } from "@/api/statistics";
import {gradientColors_options9, option7, option8, option9} from "./chartData.js"
defineProps(["height"])

// 3 本年度学院成果TOP5
const unitAchievementStatsTop5 = async () => {
  const res = await echartsApi.unitAchievementStatsTop5()
  if (res.code == 200) {
    let xAxisData = []
    let seriesData = []
    res.data.forEach((item, index) => {
      seriesData.push({
        value: item.totalAchievement,
        itemStyle: {
          color: index%2===0 ? "#FEC006" : "#00BFF3"
        }
      })
      xAxisData.push(item.unitName)
    });
    option7.value.xAxis.data = xAxisData
    option7.value.series[0].data = seriesData
  }
};

// 近五年成果数量
  
const fiveYTotalAchievement = async () => {
  const res = await echartsApi.fiveYTotalAchievement()
  if (res.code == 200) {
    let xAxisData = []
    let seriesData = []
    
    res.data.forEach((item, index) => {
      xAxisData.push(item.annual)
      seriesData.push(item.totalAchievement)
    })
    option8.value.xAxis.data = xAxisData
    option8.value.series[0].data = seriesData
  }
};

// 近五年获奖情况
const fiveYHonorStats = async () => {
  const res = await echartsApi.fiveYHonorStats()
  if (res.code == 200) {
    let yAxisData = []
    let seriesData = []
    res.data.forEach((item, index) => {
      seriesData.push({
        value: item.honorNum,
        itemStyle: {
          color: gradientColors_options9[index]
        }
      })
      yAxisData.push(item.annual)
    });
    option9.value.yAxis.data = yAxisData
    option9.value.series[0].data = seriesData
  }
};


unitAchievementStatsTop5()
fiveYTotalAchievement()
fiveYHonorStats()

</script>